/*
 * Created by Spear (http://www.codernet.es), spear@codernet.es
 * Coordinator of XNA Community (http://www.codeplex.com/XNACommunity)
 * 
 */
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace XMas
{
    /// <summary>
    /// Class to store skeleton data, all plugins have to store in this format
    /// </summary>
    /// <remarks>
    /// Stolen from Spear (http://www.codernet.es), spear@codernet.es
    /// Coordinator of XNA Community (http://www.codeplex.com/XNACommunity)
    /// </remarks>
    public class CSkeletonData
    {
        /// <summary>
        /// Skeleton node, aka bone
        /// </summary>
        public class CSkeletonNode
        {
            /// <summary>
            /// Bone position
            /// </summary>
            public Vector3 pos;
            /// <summary>
            /// Bone rotation
            /// </summary>
            public Quaternion oriented;
            /// <summary>
            /// Parent bone
            /// </summary>
            public int parent;
        };

        /// <summary>
        /// Frame data, a list of all nodes in one frame
        /// </summary>
        public class CFramesData
        {
            /// <summary>
            /// Bone list
            /// </summary>
            public List<CSkeletonNode> list_skeleton = new List<CSkeletonNode>();
        };

        /// <summary>
        /// Animation data, a list of frames
        /// </summary>
        public class CAnimationData
        {
            /// <summary>
            /// Frame rate
            /// </summary>
            public float frame_rate;
            /// <summary>
            /// Frame list
            /// </summary>
            public List<CFramesData> list_frames = new List<CFramesData>();
        };

        /// <summary>
        /// Matrix to concat with final result, some exporters export with aditional rotations
        /// </summary>
        public Matrix worldModelTransform = Matrix.Identity;

        /// <summary>
        /// Dictionary with all animations
        /// </summary>
        public Dictionary<string, CAnimationData> list_animations = new Dictionary<string,CAnimationData>();
        /// <summary>
        /// Matrix with skeleton pose
        /// </summary>
        public List<Matrix> bind_skeleton = new List<Matrix>();

        /// <summary>
        /// Matrix with inverse skeleton pose
        /// </summary>
        public List<Matrix> inverse_bind_skeleton = new List<Matrix>();
        
        /// <summary>
        /// List with skeleton bin normals
        /// </summary>
        public List<Vector3> binormals = new List<Vector3>();
        /// <summary>
        /// List with skeleton tangents
        /// </summary>
        public List<Vector3> tangents = new List<Vector3>();
        /// <summary>
        /// List with skelento normals
        /// </summary>
        public List<Vector3> normals = new List<Vector3>();

        /// <summary>
        /// Add animation
        /// </summary>
        /// <param name="name">Name</param>
        /// <param name="animation_data">Animation data</param>
        public void addAnimation(string name, CAnimationData animation_data) 
        {
            list_animations.Add(name, animation_data);
        }

  }
}
